package com.testapp.bluetoothtest08.Judge;




import com.alibaba.fastjson.JSONObject;
import com.testapp.bluetoothtest08.Constant.Constants;
import com.testapp.bluetoothtest08.File.FirstCodeFile;
import com.testapp.bluetoothtest08.File.Statement;
import com.testapp.bluetoothtest08.Http.OkHttp;



public class IsRed {
    OkHttp http = new OkHttp();


    public void judge(int verificationCode){
        new Thread(new Runnable() {
            @Override
            public void run() {
                //打印一下code列表
//                for (String[] strings : Constants.code) {
//                    for (String string : strings) {
//                        System.out.println(string);
//                    }
//                }
                System.out.println("code [0][0] -----> "+Constants.code[0][0]);
//                System.out.println("t1  -----  >"+Constants.t1);
                System.out.println("key ----> "+ Constants.key);
                //把t和key放入json
                try {
                    JSONObject obj =new JSONObject();
                    String t1 = new FirstCodeFile().read();
                    System.out.println("t1  -----  >"+t1);
                    obj.put("t",t1);
                    obj.put("key",Constants.key);
                    obj.put("verificationCode",verificationCode);
                    System.out.println("obj ---> "+obj.toString());
                    String result = http.httpPostWithToken(Constants.UPLOAD_RED_URL,obj.toJSONString());
                    System.out.println("服务器返回的结果 ----> "+result);
                    if(result!=null){
                        if(result.contains("成功")){
                            new Statement().write("确诊者");
                        }
                    }


                } catch (Exception e) {
                    e.printStackTrace();

                }
            }
        }).start();
    }

}
